﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SupportMenuPanel : OptionBasePanel
{
    public Image preShow;
    public Texture2D texDefender, texFactory;

    public override void OnEnter()
    {
        base.OnEnter();
        preShow.color = new Color(1, 1, 1, 0);
        Vector2 texSize = new Vector2(ViewController.Instance.DistanceToScreen(ConstOfMap.xGap) / 2, ViewController.Instance.DistanceToScreen(ConstOfMap.yGap) / 2);
        preShow.GetComponent<RectTransform>().sizeDelta = texSize;
    }
    protected override void UpOptionStatus()
    {
        base.UpOptionStatus();
        preShow.sprite = Sprite.Create(texDefender, new Rect(0, 0, texDefender.width, texDefender.height), new Vector2(0.5f, 0.5f));
        preShow.color = new Color(1, 1, 1, 0.5f);
    }

    protected override void DownOptionStatus()
    {
        base.DownOptionStatus();
        preShow.color = new Color(1, 1, 1, 0);
    }

    protected override void RightOptionStatus()
    {
        base.RightOptionStatus();
        preShow.sprite = Sprite.Create(texFactory, new Rect(0, 0, texFactory.width, texFactory.height), new Vector2(0.5f, 0.5f));
        preShow.color = new Color(1, 1, 1, 0.5f);
    }

    protected override void LeftOptionStatus()
    {
        base.LeftOptionStatus();
        preShow.color = new Color(1, 1, 1, 0);
    }

    protected override void DoUpOption()
    {
        base.DoUpOption();
        if (!construction(BuildingType.Nut))
            return;
        UIManager.Instance.PopPanel();
        UIManager.Instance.PopPanel();
    }

    protected override void DoRightOption()
    {
        base.DoRightOption();
        if (!construction(BuildingType.Production))
            return;
        UIManager.Instance.PopPanel();
        UIManager.Instance.PopPanel();
    }


    protected override void setCostText()
    {
        left1.text = "";
        left2.text = "";
        down1.text = "";
        down2.text = "";
        up1.text = "AP:" + BuildingManager.Instance.GetRequiredCost(BuildingType.Nut);
        up2.text = "G:" + BuildingManager.Instance.GetRequiredAP(BuildingType.Nut);
        right1.text = "AP:" + BuildingManager.Instance.GetRequiredCost(BuildingType.Production);
        right2.text = "G:" + BuildingManager.Instance.GetRequiredAP(BuildingType.Production);
    }

    protected override void DoDownOption()
    {
        base.DoDownOption();
        MessageController.Instance.SendMsg("敬请期待");
    }

    protected override void DoLeftOption()
    {
        base.DoLeftOption();
        MessageController.Instance.SendMsg("敬请期待");
    }
}
